package com.battle.service.controller.web;

import com.battle.pojo.param.trainingGroup.GetTrainingDataParam;
import com.battle.pojo.param.trainingGroup.GetTrainingGroupNumberListParam;
import com.battle.pojo.param.trainingGroup.GetTrainingNumberListParam;
import com.battle.pojo.param.trainingGroup.GetTrainingSoleNumberListParam;
import com.battle.pojo.param.trainingProgram.*;
import com.battle.pojo.vo.trainingGroup.GetTrainingDataVo;
import com.battle.pojo.vo.trainingGroup.GetTrainingGroupNumberVo;
import com.battle.pojo.vo.trainingGroup.GetTrainingNumberVo;
import com.battle.pojo.vo.trainingGroup.GetTrainingSoleNumberVo;
import com.battle.pojo.vo.trainingProgram.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.ApiResult;
import nirvana.core.domains.vo.PageResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/训练项目
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/trainingProgram/web")
public class TrainingProgramWebController {

    private final TrainingProgramService service;

    public TrainingProgramWebController(TrainingProgramService service) {
        this.service = service;
    }


    /**
     * 创建训练项目
     *
     * @param param
     * @return
     */
    @PostMapping("/createTrainingProgram")
    public ApiResult createTrainingProgram(@RequestBody @Valid CreateTrainingProgramParam param) {
        service.createTrainingProgram(param);
        return ApiResult.ok();
    }


    /**
     * 修改训练项目
     *
     * @param param
     */
    @PutMapping("/editTrainingProgram")
    public ApiResult editTrainingProgram(@RequestBody @Valid EditTrainingProgramParam param) {
        service.editTrainingProgram(param);
        return ApiResult.ok();
    }

    /**
     * 移除训练项目
     *
     * @param id
     */
    @DeleteMapping("/removeTrainingProgram")
    public ApiResult removeTrainingProgram(@RequestParam("id") Long id) {
        service.removeTrainingProgram(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用训练项目
     *
     * @param id
     */
    @GetMapping("/enabledTrainingProgram")
    public ApiResult enabledTrainingProgram(@RequestParam("id") Long id) {
        service.enabledTrainingProgram(id);
        return ApiResult.ok();
    }

    /**
     * 获取训练项目详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getTrainingProgram")
    public ApiResult<GetTrainingProgramVo> getTrainingProgram(@RequestParam("id") Long id) {
        GetTrainingProgramVo vo = service.getTrainingProgram(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取训练项目列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getTrainingProgramList")
    public ApiResult<PageResult<GetTrainingProgramListVo>> getTrainingProgramList(@RequestBody GetTrainingProgramListParam param) {
        PageResult<GetTrainingProgramListVo> result = service.getTrainingProgramList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取训练项目下拉列表
     *
     * @return
     */
    @PostMapping("/getTrainingProgramDownList")
    public ApiResult<List<GetTrainingProgramDownListVo>> getTrainingProgramDownList(@RequestBody(required = false) @Valid GetTrainingProgramDownListParam param) {
        List<GetTrainingProgramDownListVo> list = service.getTrainingProgramDownList(param);
        return ApiResult.ok(list);
    }

    /**
     * 训练量排行榜
     *
     * @return
     */
    @PostMapping("/getTrainingNumberList")
    public ApiResult<List<GetTrainingNumberVo>> getTrainingNumberList(@RequestBody(required = false) @Valid GetTrainingNumberListParam param) {
        List<GetTrainingNumberVo> list = service.getTrainingNumberList(param);
        return ApiResult.ok(list);
    }

    /**
     * 项目训练量统计
     *
     * @return
     */
    @PostMapping("/getTrainingGroupNumberList")
    public ApiResult<List<GetTrainingGroupNumberVo>> getTrainingGroupNumberList(@RequestBody(required = false) @Valid GetTrainingGroupNumberListParam param) {
        List<GetTrainingGroupNumberVo> list = service.getTrainingGroupNumberList(param);
        return ApiResult.ok(list);
    }

    /**
     * 人员训练量统计
     *
     * @return
     */
    @PostMapping("/getTrainingSoleNumberList")
    public ApiResult<List<GetTrainingSoleNumberVo>> getTrainingSoleNumberList(@RequestBody(required = false) @Valid GetTrainingSoleNumberListParam param) {
        List<GetTrainingSoleNumberVo> list = service.getTrainingSoleNumberList(param);
        return ApiResult.ok(list);
    }

    /**
     * 训练量增长趋势
     *
     * @return
     */
    @PostMapping("/getTrainingDataVo")
    public ApiResult<GetTrainingDataVo> getTrainingDataVo(@RequestBody(required = false) @Valid GetTrainingDataParam param) {
        GetTrainingDataVo list = service.getTrainingDataVo(param);
        return ApiResult.ok(list);
    }
}

